//
//  HomeDefaultStyleTableViewCell.swift
//  NDAi
//
//  Created by 丸子 on 2024/7/1.
//

import UIKit

class HomeDefaultStyleTableViewCell: UITableViewCell {
    
//     lazy var tipsLb: UILabel = {
//        let label = UILabel()
//        label.font = UIFont.pingFangSCRegular(ofSize: 13)
//        label.textColor = .white
//        label.text = "呵呵"
//        label.backgroundColor = Theme.color.main
//        label.allRound(10)
//        return label
//    }()
//    
    private lazy var iconIV: UIImageView = {
       let imageView = UIImageView()
        return imageView
    }()
    
    private lazy var titleLb: UILabel = {
        let label = UILabel()
        label.font = UIFont.pingFangSCRegular(ofSize: 14)
        label.textColor = Theme.color.text_d1
        label.text = "呵呵"
        label.numberOfLines = 1
        return label
    }()
    
    private lazy var descLb: UILabel = {
        let label = UILabel()
        label.font = UIFont.pingFangSCRegular(ofSize: 12)
        label.textColor = Theme.color.text_d2
        label.text = "呵呵"
        label.numberOfLines = 1
        return label
    }()
    
    private lazy var moreIV: UIImageView = {
       let imageView = UIImageView()
        imageView.image = UIImage(named: "icon_Mine_更多")
        return imageView
    }()
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.addSubviews([iconIV, titleLb, descLb, moreIV])
        contentView.backgroundColor = .clear
        selectionStyle = .none
//        tipsLb.snp.makeConstraints { make in
//            make.centerY.equalToSuperview()
//            make.leading.equalToSuperview().offset(24)
//            make.height.equalTo(20)
//        }
//        tipsLb.setContentHuggingPriority(.required, for: .horizontal) // 确保 contentLb 在垂直方向上有优先权

        iconIV.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.leading.equalToSuperview().offset(24)
            make.width.height.equalTo(44)
        }
        
        titleLb.snp.makeConstraints { make in
            make.top.equalTo(iconIV.snp.top).offset(4)
            make.leading.equalTo(iconIV.snp.trailing).offset(10)
            make.trailing.equalTo(moreIV.snp.leading).offset(-10)
        }
        
        descLb.snp.makeConstraints { make in
            make.top.equalTo(titleLb.snp.bottom).offset(2)
            make.leading.equalTo(iconIV.snp.trailing).offset(10)
            make.trailing.equalTo(moreIV.snp.leading).offset(-10)
        }
        
        moreIV.snp.makeConstraints { make in
            make.trailing.equalToSuperview().offset(-24)
            make.centerY.equalToSuperview()
            make.width.equalTo(4)
            make.height.equalTo(8)
        }
    }
    
    func setup(model:PlazaListModel) {
//        if var title = model.title {
//            title = title.replacingOccurrences(of: " ", with: "")
//            title = title.replacingOccurrences(of: "\n", with: "")
//            self.tipsLb.text = "  \(title)  "
//        }
        self.iconIV.sd_setImage(with: URL(string: model.img_logo ?? ""))
        titleLb.text = model.title ?? ""
        self.descLb.text = model.item?.first?.question ?? ""
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
class HomeCheckMoreCell: UITableViewCell {
    
     lazy var tipsLb: UILabel = {
        let label = UILabel()
        label.font = UIFont.pingFangSCRegular(ofSize: 13)
        label.textColor = Theme.color.text_d3
        label.text = "显示更多 ↓"
        return label
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        contentView.addSubviews([tipsLb])
        contentView.backgroundColor = .clear
        
        tipsLb.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.centerX.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
